<?php

namespace App\Http\Controllers;

use App\Models\ArticlePages;
use Illuminate\Http\Request;

use App\Http\Controllers\Controller;

class ArticlePagesController extends CommonController
{
    /**
     *获取关于我们页面
     */
    public function getAbout()
    {
        $list = ArticlePages::where('type', 'about')->first();

        return view('articlepages.detail')->with('list', $list)->with('type', 'about');
    }

    /**
     *编辑页面内容
     */
    public function postEdit(Request $request)
    {
        $data = $request->input();
        ArticlePages::where('type', $data['type'])->update(['content' => $data['content']]);

        return AjaxCallbackMessage('编辑成功', true, url('articlepages/' . $data['type']));
    }

    /**
     *获取加入我们页面
     */
    public function getJoin()
    {
        $list = ArticlePages::where('type', 'join')->first();

        return view('articlepages.detail')->with('list', $list)->with('type', 'join');
    }

    /**
     *获取服务条款页面
     */
    public function getTerms()
    {
        $list = ArticlePages::where('type', 'terms')->first();

        return view('articlepages.detail')->with('list', $list)->with('type', 'terms');
    }

    /**
     *获取联系我们页面
     */
    public function getContact()
    {
        $list = ArticlePages::where('type', 'contact')->first();

        return view('articlepages.detail')->with('list', $list)->with('type', 'contact');
    }
}
